package cn.itheima.web;

import cn.itheima.domain.User;
import cn.itheima.service.UserService;
import cn.itheima.service.UserServiceImp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author: cuisensen
 * data: 2018/7/5.
 * time: 16:06.
 */
@WebServlet("/oparatorAndShow")
public class OparatorAndShowServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String uid=request.getParameter("uid");
        UserService us=new UserServiceImp();
        User user = us.findUserById(uid);
        request.setAttribute("setUser",user);
        request.setAttribute("flag","exist");
        request.getSession().setAttribute("includePage","addUser.jsp");
        request.getRequestDispatcher(request.getContextPath()+"/index.jsp").forward(request,response);
    }
}
